/*
 * Implement Queue w/ Stack
 */
import java.util.Stack;
public class ch3_5_queue<E> {
	Stack<E> s1, s2;
	public ch3_5_queue(){
		s1 = new Stack<E>();
		s2 = new Stack<E>();
	}
	
	public int size(){
		return s1.size()+s2.size();
	}
	
	public void add(T value){
		s1.push(value);
	}
	public T peek(){
		if(!s2.isEmpty())
			return s2.peek();
		else{
			while(!s1.isEmpty())
				s2.push(s1.pop());
			return s2.peek();
		}
	}
	
	public T remove(){
		if(!s2.isEmpty())
			return s2.pop();
		else{
			while(!s1.isEmpty())
				s2.push(s1.pop());
			return s2.pop();
		}
		
	}
}